package com.ssm.controller;

import com.ssm.entity.Student;
import com.ssm.service.StudentService;
import com.ssm.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/student")
@CrossOrigin //解决跨域问题，有局限性，只能在这个控制器起作用
public class StudentController {

    @Autowired
    private StudentService studentService;
    //1.获取所有的学生
    @GetMapping("/list")
    public List<Student> list() {
        return studentService.findAll();
    }


    //2.分页查询学生信息
    @GetMapping("/findByPage")
    public PageResult<Student> findByPage(@RequestParam("page") Integer page, @RequestParam("pageSize") Integer pageSize){
        return studentService.findByPage(page,pageSize);
    }

}
